<?php
/**
 * bll task
 * @package app-member_lib_bll_member
 */
load_lib('/bll/member/base');
load_lib('/dao/member/taskdao');
/**
 * bll task
 * @author pandajingjing
 * @package app-member_lib_bll_member
 */
class bll_member_task extends bll_member_base{

	/**
	 * 处理过的消息数
	 * @var int
	 */
	private $_intMsgCnt=0;

	/**
	 * 处理user的消息队列
	 */
	function doMemberMsg(){
		dao_member_taskdao::consumeMessage(array(
				$this,
				'processMsg'
		));
		return $this->_intMsgCnt;
	}

	/**
	 * 队列消息处理逻辑
	 * @param mix $p_mixMsg
	 */
	function processMsg($p_mixMsg){
		$arrParam=$p_mixMsg->getBody();
		switch($arrParam['MSGTYPE']){
			case 1: //新增用户
				$arrLoginInfo=array(
						'USERNAME'=>$arrParam['USERNAME'],
						'EMAIL'=>$arrParam['USERNAME'],
						'USERPWD'=>$arrParam['USERPWD'],
						'USERID'=>$arrParam['USERID'],
						'LASTUPD'=>$arrParam['REGTIME']
				);
				dao_member_taskdao::addUserLoginInfo($arrLoginInfo);
				$arrTimeInfo=array(
						'USERID'=>$arrParam['USERID'],
						'THISTIME'=>$arrParam['REGTIME'],
						'THISIP'=>$arrParam['REGIP']
				);
				dao_member_taskdao::addUserLoginTime($arrTimeInfo);
				break;
			case 2: //用户登录
				$arrUserBaseInfo=dao_member_taskdao::getUserLoginTime($arrParam['USERID']);
				if(null==$arrUserBaseInfo){

				}else{
					$arrUpdInfo=array(
							'USERID'=>$arrParam['USERID'],
							'THISIP'=>$arrParam['LOGINIP'],
							'THISTIME'=>$arrParam['LOGINTIME'],
							'LASTIP'=>$arrUserBaseInfo['THISIP'],
							'LASTTIME'=>$arrUserBaseInfo['THISTIME']
					);
					dao_member_taskdao::updUserLoginTime($arrUpdInfo);
				}
				break;
			case 3: //用户修改密码
				$arrUpdInfo=array(
						'USERID'=>$arrParam['USERID'],
						'USERPWD'=>$arrParam['USERPWD'],
						'USERNAME'=>$arrParam['USERNAME']
				);
				dao_member_taskdao::updUserLoginInfo($arrUpdInfo);
				break;
			case 4: //用户修改基础资料
				$arrUpdInfo=array(
						'EMAIL'=>$arrParam['EMAIL'],
						'USERID'=>$arrParam['USERID'],
						'LASTUPD'=>$arrParam['LASTUPD']
				);
				dao_member_taskdao::updUserLoginInfo($arrUpdInfo);
				break;
		}
		++$this->_intMsgCnt;
		$p_mixMsg->fade();
	}

}